<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:pm="livcos.org/ns/pm"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:f="livcos.org/ns/xslt/function"
  xmlns="http://www.w3.org/1999/xhtml"
  exclude-result-prefixes="pm xs f">
  
  <xsl:import href="../../style/base.xsl" />
	
	<xsl:variable name="testTodoUri" select="'/livcos.org/WorkLog/data/ToDo'"/>

	<xsl:variable name="startDate" select="xs:date('2009-01-01')"/>
	<!-- 0: Monday; 1: Tuesday; 2: Wednesday; 3: Thursday; 4: Friday; 5: Saturday; 6: Sunday -->
	<xsl:variable name="startWeekDay" select="3"/>
	<xsl:variable name="days" as="xs:date*">
		<xsl:for-each select="0 to 100">
			<xsl:sequence select="$startDate + (xs:dayTimeDuration('P1D') * xs:double(.))"/>
		</xsl:for-each>
	</xsl:variable>
	
	<xsl:template match="/">
		<html id="{$callerObjId}">
			<head>
				<title>Time Records</title>
				<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
				<meta name="served" content="{current-dateTime()}"/>
				<link href="{$toRootPath}/livcos.org/web/css/global.css" rel="stylesheet" type="text/css"/>
				<link href="{$toRootPath}/livcos.org/web/css/web.css" rel="stylesheet" type="text/css"/>
				<link href="{$toRootPath}/livcos.org/web/css/doc.css" rel="stylesheet" type="text/css"/>
				<link href="css/TimeRecords.css" rel="stylesheet" type="text/css"/>
				<script type="text/javascript" src="{$toRootPath}/livcos.org/web/script/util.js">
      		<xsl:comment> </xsl:comment></script>
				<script type="text/javascript" src="{$toRootPath}/livcos.org/web/script/E.js">
					<xsl:comment> </xsl:comment></script>
				<script type="text/javascript" src="{$toRootPath}/livcos.org/web/script/init.js">
					<xsl:comment> </xsl:comment></script>
				<script type="text/javascript" src="{$toRootPath}/livcos.org/web/script/gui.js">
					<xsl:comment> </xsl:comment></script>
				<script type="text/javascript" src="script/TimeRecords.js">
					<xsl:comment> </xsl:comment></script>
			</head>
      <body>
				<div>
					<div class="table">
						<div id="label">Task</div>
						<div id="header">
							<div id="headContainer" class="row">
								<xsl:for-each select="$days">
									<div>
										<xsl:value-of select="format-number(day-from-date(.), '00')"/>
									</div>
								</xsl:for-each>
							</div>
						</div>
						<div id="side">
							<div id="sideContainer">
								<xsl:apply-templates select="doc($testTodoUri)//pm:task" mode="side"/>
							</div>
						</div>
						<div id="body">
							<xsl:apply-templates select="doc($testTodoUri)//pm:task" mode="body"/>
						</div>
					</div>
				</div>
      </body>
    </html>
  </xsl:template>
  
	<xsl:template match="pm:task" mode="side">
		<div class="row">
			<xsl:if test="position() mod 2">
				<xsl:attribute name="class">row odd</xsl:attribute>
			</xsl:if>
			<xsl:value-of select="pm:title"/>
		</div>
	</xsl:template>
	
	<xsl:template match="pm:task" mode="body">
		<div class="row">
			<xsl:if test="position() mod 2">
				<xsl:attribute name="class">row odd</xsl:attribute>
			</xsl:if>
			<xsl:for-each select="1 to 100">
				<xsl:variable name="weekDay" select="($startWeekDay + position() - 1) mod 7"/>
				<div contenteditable="true">
					<xsl:if test="($weekDay = 5) or ($weekDay = 6)">
						<xsl:attribute name="class">weekend</xsl:attribute>
					</xsl:if>
					<xsl:text>&#160;</xsl:text>
				</div>
			</xsl:for-each>
		</div>
	</xsl:template>
	
</xsl:stylesheet>